package main.chapter2

fun main(args: Array<String>) {
    //具名参数，由于有名称因此可以不按照参数顺序
    println(sum(arg2 = 3, arg1 = 2))
    //变长参数在多个参数下需要使用具名参数来传参
    hello(1, 3, 4, 5, string = "Hello,vararg")
    val array: IntArray = intArrayOf(1, 3, 5, 7, 9)
    //*代表展开数组
    hello(*array, string = "hello",version = 1.0)
    hello(*array, string = "hello")
}

private fun sum(arg1: Int, arg2: Int) = arg1 + arg2
//vararg变长参数,version=3.0指定了默认参数
private fun hello(vararg ints: Int, string: String,version: Double = 3.0) {
    ints.forEach(::println)
    println(string)
    println(version)
}